using HttpProxy.Models.Account;
using HttpProxy.Models.WebResponse;
using System.Web.Http;

namespace HttpProxy.Controllers
{
  public class UserController : ApiController
  {
    [HttpPost, Route("api/user/login")]
    public BaseResponse<TokenResponse> Login(LoginRequest request)
    {
      return new BaseResponse<TokenResponse>
      {
        data = new TokenResponse
        {
          token = "admin"
        }
      };
    }

    [HttpGet, Route("api/user/info")]
    public BaseResponse<UserInfo> Info(string token) {
      return new BaseResponse<UserInfo>
      {
        data = new UserInfo
        {
          name = "admin",
          introduction = "管理员",
          roles = new string[] { "admin" }
        }
      };
    }

    [HttpPost, Route("api/user/logout")]
    public BaseResponse<bool> Logout(string token) {
      return new BaseResponse<bool>
      {
        data = true
      };
    }
  }
}
